// 诡异复杂的映射类型

// 让 type EventRec = { click: (event: MouseEvent) => any; keyUp: (event: KeyEvent) => any }
type MouseEvent = { eventType: "click", x: number; y: number }
type KeyEvent = { eventType: "keyUp", key: number }

type EventFunction<Events extends Record<string, any>, EventKey extends keyof Events> = {
  // [Event in Events as Event extends Events ? Event[EventKey] : never]: (event: Event) => any
  [Event in Events as Event[EventKey]]: (event: Event) => any
}

type EventRec = EventFunction<MouseEvent| KeyEvent, "eventType">
export{}